package mvndemo.hello;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import mvndemo.model.User;

public class UserAction {
	private Map<String,Object> dataMap;  
    private String key = "Just see see";  
      
    public String json() {  
    	HttpServletRequest request=ServletActionContext.getRequest();
    	String name=request.getParameter("name");
    	String pwd=request.getParameter("pwd");
    	System.out.println(name+"--"+pwd);
        // dataMap中的数据将会被Struts2转换成JSON字符串，所以这里要先清空其中的数据  
        dataMap = new HashMap<String, Object>();  
        List<User> lists=new ArrayList<User>();
        for(int i=0;i<3;i++){
        	 User user = new User();  
             user.setName(name+"--"+i);  
             user.setPassword(pwd+"--"+i);  
          lists.add(user);
        }
        dataMap.put("lists", lists);  
        // 放入一个是否操作成功的标识  
        dataMap.put("success", true);  
        // 返回结果  
        return "json";  
    }
    public String toIndex(){
    	return "index";
    }

	public Map<String, Object> getDataMap() {
		return dataMap;
	}

	public void setDataMap(Map<String, Object> dataMap) {
		this.dataMap = dataMap;
	}  
    

}
